<extend name="public@base5"/>
<block name="main">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="{:url('Rbac/index')}">{:lang('ADMIN_RBAC_INDEX')}</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{:url('Rbac/roleAdd')}">{:lang('ADMIN_RBAC_ROLEADD')}</a>
            </li>
        </ul>
        <form action="" method="post" class="margin-top-20">
            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <th width="40">ID</th>
                    <th align="left">{:lang('ROLE_NAME')}</th>
                    <th align="left">{:lang('Type')}</th>
                    <th align="left">{:lang('ROLE_DESCRIPTION')}</th>
                    <th width="60" align="left">{:lang('STATUS')}</th>
                    <th width="120">{:lang('ACTIONS')}</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="roles" item="vo">
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.name}</td>
                        <td>
                            <switch name="$vo.type">
                                <case value="admin">{:lang('Admin')}</case>
                                <case value="user">{:lang('User')}</case>
                                <default>{$vo.type}</default>
                            </switch>
                        </td>
                        <td>{$vo.remark}</td>
                        <td>
                            <if condition="$vo['status'] eq 1">
                                <span class="badge text-bg-success">{:lang('Enabled')}</span>
                                <else/>
                                <span class="badge text-bg-danger">{:lang('Disabled')}</span>
                            </if>
                        </td>
                        <td>
                            <if condition="$vo['id'] eq 1">
                            <span class="btn btn-xs btn-primary disabled" title="{:lang('ROLE_SETTING')}"
                                  data-toggle="tooltip">
                                <i class="fa fa-cog fa-fw"></i>
                            </span>
                                <span class="btn btn-xs btn-success disabled" title="{:lang('EDIT')}"
                                      data-toggle="tooltip">
                                <i class="fa fa-edit fa-fw"></i>
                            </span>
                                <span class="btn btn-xs btn-danger disabled"
                                      title="{:lang('DELETE')}"
                                      data-toggle="tooltip">
                                <i class="fa fa-trash fa-fw"></i>
                            </span>
                                <else/>
                                <a class="btn btn-xs btn-primary" href="javascript:"
                                   onclick="openAuthorizeDialog(this)"
                                   data-href="{:url('Rbac/authorize',array('id'=>$vo['id']))}"
                                   title="{:lang('ROLE_SETTING')}" data-toggle="tooltip">
                                    <i class="fa fa-cog fa-fw"></i>
                                </a>
                                <a class="btn btn-xs btn-success" href="{:url('Rbac/roleEdit',array('id'=>$vo['id']))}"
                                   title="{:lang('EDIT')}" data-toggle="tooltip">
                                    <i class="fa fa-edit fa-fw"></i>
                                </a>
                                <a class="btn btn-xs btn-danger js-ajax-delete"
                                   href="javascript:"
                                   data-href="{:url('Rbac/roleDelete',array('id'=>$vo['id']))}"
                                   title="{:lang('DELETE')}" data-toggle="tooltip">
                                    <i class="fa fa-trash fa-fw"></i>
                                </a>
                            </if>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        </form>
    </div>
</block>
<block name="scripts">
    <script>
        function openAuthorizeDialog(obj) {
            var $obj = $(obj);
            var href = $obj.data('href');
            parent.openIframeLayer(href, "{:lang('ROLE_SETTING')}", {
                area: GV.IS_MOBILE ? ['100%', '100%'] : ['95%', '95%'],
                offset: GV.IS_MOBILE ? ['0px', '0px'] : 'auto',
                // btn: ['确定', '取消'],
                yes: function (index, layero) {
                    console.log(layero);
                    var iframeWin = parent.window[layero.find('iframe')[0]['name']];
                    //iframeWin.confirm();
                    parent.layer.close(index); //如果设定了yes回调，需进行手工关闭
                },
                end: function () {
                }
            });
        }
    </script>
</block>
